package cn.eaay.stock.job;

import cn.eaay.stock.service.StockRtInfoService;
import cn.eaay.stock.service.StockTimerService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 股票数据采集定时任务
 */
@Component
public class StockJobHandler {

    private static final Logger logger = LoggerFactory.getLogger(SimpleJobHandler.class);

    @Resource
    private StockTimerService stockTimerService;

    @Resource
    private StockRtInfoService stockRtInfoService;

    /**
     * 定时采集大盘指数信息
     */
    @XxlJob("stockMarketIndexInfoTask")
    public void getStockMarketIndexInfoTask() {
        stockTimerService.addMarketIndexInfoAndLogPrice();
    }

    /**
     * 定时采集个股数据
     */
    @XxlJob("stockRtInfoTask")
    public void getStockRtInfoTask() {
        logger.info("开始采集个股数据");
        stockRtInfoService.getStockRtInfo();
        logger.info("个股数据采集完毕");
    }
}
